package net.sudot.chess.business.service;

import net.sudot.chess.business.dao.InviteRecordDao;
import net.sudot.chess.business.dto.CustomerDetailDTO;
import net.sudot.chess.business.model.Customer;
import net.sudot.chess.business.model.InviteRecord;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.Instant;
import java.util.Date;
import java.util.List;

/**
 * 邀请记录
 *
 * @author tangjialin on 2018-03-25.
 */
@Service
public class InviteRecordService extends BaseService<InviteRecord> {

    @Resource
    private InviteRecordDao inviteRecordDao;

    /**
     * 获取被邀请者的邀请人信息
     *
     * @param invitee 被邀请者的用户主键
     * @return 返回用户的邀请人信息
     */
    public Customer findByInvitee(Long invitee) {
        return inviteRecordDao.findByInvitee(invitee);
    }

    /**
     * 获取邀请者邀请的用户和其周期内的充值金额
     *
     * @param inviter 邀请者的用户主键
     * @param start   起始时间
     * @param end     结束时间
     * @return 返回邀请者邀请的用户和其周期内的充值金额
     */
    public List<CustomerDetailDTO> findListByInviter(Long inviter, Instant start, Instant end) {
        return inviteRecordDao.findListByInviter(inviter, start, end);
    }
}
